package org.groupg.practice;

import net.sf.jsqlparser.JSQLParserException;
import net.sf.jsqlparser.expression.Expression;
import net.sf.jsqlparser.expression.ExpressionVisitorAdapter;
import net.sf.jsqlparser.expression.operators.relational.EqualsTo;
import net.sf.jsqlparser.parser.CCJSqlParserUtil;

public class ExpressionVisitorExample {
    public static void main(String[] args) throws JSQLParserException {
        String whereClause = "age > 25 AND (department = 'IT' OR status = 'active')";
        Expression expr = CCJSqlParserUtil.parseCondExpression(whereClause);

        expr.accept(new ExpressionVisitorAdapter() {
            @Override
            public void visit(EqualsTo equalsTo) {
                System.out.println("发现等值条件: "
                    + equalsTo.getLeftExpression() + " = "
                    + equalsTo.getRightExpression());
                super.visit(equalsTo);
            }
        });
    }
}
